home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / plnk081.zip / pilot-link.0.8.1 / test-connector.c < prev    next >
C/C++ Source or Header  |  1997-06-13  |  854b  |  43 lines

  1. /* test-connector.c:  Test a unix-to-unix connection
  2.  *
  3.  * This is free software, licensed under the GNU Public License V2.
  4.  * See the file COPYING for details.
  5.  */
  6.  
  7. /* See test-acceptor.c for more information */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include "pi-source.h"
  12. #include "pi-socket.h"
  13. #include "pi-dlp.h"
  14.  
  15. int main(int argc, char *argv[])
  16. {
  17.   struct pi_sockaddr addr;
  18.   int sd;
  19.   char buffer[64];
  20.   int ret;
  21.  
  22.   if (!(sd = pi_socket(PI_AF_SLP, PI_SOCK_STREAM, PI_PF_PADP))) {
  23.     perror("pi_socket");
  24.     exit(1);
  25.   }
  26.     
  27.   addr.pi_family = PI_AF_SLP;
  28.   strcpy(addr.pi_device,"/dev/ttyp9");
  29.   
  30.   ret = pi_connect(sd, (struct sockaddr*)&addr, sizeof(addr));
  31.   if(ret == -1) {
  32.     perror("pi_connect");
  33.     exit(1);
  34.   }
  35.   
  36.   pi_read(sd, buffer, 64);
  37.   puts(buffer);
  38.   pi_write(sd, "Sent from client", 17);
  39.  
  40.   dlp_AbortSync(sd);
  41.   exit(0);
  42. }
  43.